package pers.hl.lib_global.common

import android.text.TextUtils
import com.alibaba.android.arouter.launcher.ARouter
import pers.hl.lib_global.arouter.RouterPath

object RouteUtils {

    fun nav(path: String) {
        if (TextUtils.isEmpty(path)) {
            throw IllegalArgumentException("path can not be empty")
        }
        ARouter.getInstance().build(path).navigation()
    }

    fun navWithString(path: String, key: String, value: String) {
        if (TextUtils.isEmpty(path)) {
            throw IllegalArgumentException("path can not be empty")
        }
        ARouter.getInstance()
            .build(path)
            .withString(key, value)
            .navigation()
    }

    fun navToLogin() {
        nav(RouterPath.login)
    }

    fun navToMain() {
        nav(RouterPath.main)
    }

}